package com.aphrodite.util;

import java.util.Vector;

/**
 * TBD. Class used to map a key code to a series of characters
 * <p>
 * </p>
 * 
 * @see com.aphrodite.ui.canvaswidgets.TextBox
 * @author kentelt
 * 
 */
public class KeyMap {
	Vector characters;
	IntVector key;

	public KeyMap() {
		this(10);
	}

	public KeyMap(int initalCapacity) {
		key = new IntVector(initalCapacity, 3);
		characters = new Vector(initalCapacity, 3);
	}

	/**
	 * Does not allow repetition
	 * 
	 * @param keycode
	 * @param chars
	 */
	public void addMap(int keycode, char[] chars) {
		if (key.indexOf(keycode) > 0) {
			key.addElement(keycode);
			characters.addElement(chars);
		}
	}

	public char[] getMap(int keycode) {
		int index = key.indexOf(keycode);
		if (index > 0)
			return (char[]) characters.elementAt(index);
		else
			return null;
	}

}
